<section class="Hui-article-box">
	<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 节点管理 <span
			class="c-gray en">&gt;</span> 节点列表 <a class="btn btn-success radius r"
			style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新"><i
				class="Hui-iconfont">&#xe68f;</i></a></nav>
	<div class="Hui-article">
		<article class="cl pd-20">
			<div class="cl pd-5 bg-1 bk-gray mt-20">
				<span class="l">
					<a href="javascript:;" onclick="add()" class="btn btn-primary radius"><i
							class="Hui-iconfont">&#xe600;</i> 添加权限节点</a>
				</span>
			</div>
			<table class="table table-border table-bordered table-bg">
				<thead>
					<tr>
						<th scope="col" colspan="7">权限节点</th>
					</tr>
					<tr class="text-c">
						<th width="40">ID</th>
						<th width="200">节点名称</th>
						<th>规则</th>
						<th width="200">状态</th>
						<th width="200">操作</th>
					</tr>
				</thead>
				<tbody>
					<volist name="list" id="item1" key="key1">
						<tr class="text-c">
							<td>{$item1['id']}</td>
							<td style="text-align: left;">{$item1['auth_name']}</td>
							<td style="text-align: left;">{$item1['rule']}</td>
							<td class="td-status"><span
									class="label label-{$item1['status']==1?'success':'default'} radius">{$item1['status']==1?'已启用':'已停用'}</span>
							</td>
							<td class="td-manage">
								<if condition="$item1['status'] eq 1">
								<a title="停用" onClick="stop(this,'{$item1[id]}')" style="text-decoration:none"
									href="javascript:;"><i class="Hui-iconfont">&#xe631;</i></a>
								</if>
								<if condition="$item1['status'] eq 0">
								<a title="启用" onClick="start(this,'{$item1[id]}')" style="text-decoration:none"
									href="javascript:;"><i class="Hui-iconfont">&#xe615;</i></a>
								</if>		
								<a title="编辑" onClick="edit('{$item1[id]}')" class="ml-5" style="text-decoration:none"
									href="javascript:;"><i class="Hui-iconfont">&#xe6df;</i></a>
								<a title="删除" onClick="del('{$item1[id]}')" class="ml-5" style="text-decoration:none"
									href="javascript:;"><i class="Hui-iconfont">&#xe6e2;</i></a>
							</td>
						</tr>
						<volist name="item1.children" id="item2" key="key2">
							<tr class="text-c">
								<td>{$item2['id']}</td>
								<td style="text-align: left;">
									&emsp;{:count($item1['children'])>($key2+1)?'├':'└'}&emsp;{$item2['auth_name']}</td>
								<td style="text-align: left;">{$item2['rule']}</td>
								<td class="td-status"><span
										class="label label-{$item2['status']==1?'success':'default'} radius">{$item2['status']==1?'已启用':'已停用'}</span>
								</td>
								<td class="td-manage">
									<if condition="$item2['status'] eq 1">
									<a title="停用" onClick="stop(this,'{$item2[id]}')" style="text-decoration:none"
										href="javascript:;"><i class="Hui-iconfont">&#xe631;</i></a>
									</if>
									<if condition="$item2['status'] eq 0">
									<a title="启用" onClick="start(this,'{$item2[id]}')" style="text-decoration:none"
										href="javascript:;"><i class="Hui-iconfont">&#xe615;</i></a>
									</if>		
									<a title="编辑" onClick="edit('{$item2[id]}')" class="ml-5"
										style="text-decoration:none" href="javascript:;"><i
											class="Hui-iconfont">&#xe6df;</i></a>
									<a title="删除" onClick="del('{$item2[id]}')" class="ml-5"
										style="text-decoration:none" href="javascript:;"><i
											class="Hui-iconfont">&#xe6e2;</i></a>
								</td>
							</tr>
							<volist name="item2.children" id="item3" key="key3">
								<tr class="text-c">
									<td>{$item3['id']}</td>
									<td style="text-align: left;">
										&emsp;{:count($item1['children'])>($key2+1)?'│':'&emsp;'}&emsp;{:count($item2['children'])>($key3+1)?'├':'└'}&emsp;{$item3['auth_name']}
									</td>
									<td style="text-align: left;">{$item3['rule']}</td>
									<td class="td-status"><span
											class="label label-{$item3['status']==1?'success':'default'} radius">{$item3['status']==1?'已启用':'已停用'}</span>
									</td>
									<td class="td-manage">
										<if condition="$item3['status'] eq 1">
										<a title="停用" onClick="stop(this,'{$item3[id]}')" style="text-decoration:none"
											href="javascript:;"><i class="Hui-iconfont">&#xe631;</i></a>
										</if>
										<if condition="$item3['status'] eq 0">
										<a title="启用" onClick="start(this,'{$item3[id]}')" style="text-decoration:none"
											href="javascript:;"><i class="Hui-iconfont">&#xe615;</i></a>
										</if>		
										<a title="编辑" onClick="edit('{$item3[id]}')" class="ml-5"
											style="text-decoration:none" href="javascript:;"><i
												class="Hui-iconfont">&#xe6df;</i></a>
										<a title="删除" onClick="del('{$item3[id]}')" class="ml-5"
											style="text-decoration:none" href="javascript:;"><i
												class="Hui-iconfont">&#xe6e2;</i></a>
									</td>
								</tr>
							</volist>
						</volist>
					</volist>
				</tbody>
			</table>
		</article>
	</div>
</section>
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript">
	/*停用*/
	function stop(obj, id) {
		layer.confirm('确认要停用吗？', function (index) {
			//此处请求后台程序，下方是成功后的前台处理……

			$.ajax({
				url: "{:U('admin/auth/edit')}",
				type: 'post',
				data: {
					id: id,
					status: 0,
				},
				success: function (re) {
					if (re.code) {
						$(obj).parents("tr").find(".td-manage").prepend('<a onClick="start(this,' + id + ')" href="javascript:;" title="启用" style="text-decoration:none"><i class="Hui-iconfont">&#xe615;</i></a>');
						$(obj).parents("tr").find(".td-status").html('<span class="label label-default radius">已停用</span>');
						$(obj).remove();
						layer.msg('已停用!', { icon: 6, time: 1000 });
					} else {
						layer.msg('操作失败!', { icon: 5, time: 1000 });
					}

				}
			})


		});
	}
	/*启用*/
	function start(obj, id) {
		layer.confirm('确认要启用吗？', function (index) {
			//此处请求后台程序，下方是成功后的前台处理……
			$.ajax({
				url: "{:U('admin/auth/edit')}",
				type: 'post',
				data: {
					id: id,
					status: 1,
				},
				success: function (re) {
					if (re.code) {
						$(obj).parents("tr").find(".td-manage").prepend('<a onClick="stop(this,' + id + ')" href="javascript:;" title="停用" style="text-decoration:none"><i class="Hui-iconfont">&#xe631;</i></a>');
						$(obj).parents("tr").find(".td-status").html('<span class="label label-success radius">已启用</span>');
						$(obj).remove();
						layer.msg('已启用!', { icon: 6, time: 1000 });
					} else {
						layer.msg('操作失败!', { icon: 5, time: 1000 });
					}

				}
			})

		});
	}
	/*编辑*/
	function add(id) {
		location.href = "{:U('admin/auth/add')}";
	}
	/*编辑*/
	function edit(id) {
		location.href = "{:U('admin/auth/edit/id/" + id + "')}";
	}
	/*删除*/
	function del(id) {
		layer.confirm('权限删除须谨慎，确认要删除吗？', function (index) {
			location.href = "{:U('admin/auth/del/id/" + id + "')}";
		});
	}
</script>
<!--/请在上方写此页面业务相关的脚本-->